#ifndef __UART_H__
#define __UART_H__

#include <stdarg.h>
#include "basictype.h"
#include "uartconfig.h"

enum {
  UART_COMM_TYPE_QUERY = 0, //查询方式
  UART_COMM_TYPE_INTERRUPR, //中断方式
  UART_COMM_TYPE_DMA,       // DMA方式
  UART_COMM_TYPE_COUNT,
};

extern DevHandle Uart_GetDev(const char *pDevName);
extern INT32 Uart_GetDevCount(void);

extern void Uart_InitModule(void);
extern DevHandle Uart_Open(const char *pDevName,UartConfig_t *pConfig);
extern BOOL32 Uart_LinkBuffer(DevHandle devHandle, UINT8 *txBuf, 
                      UINT32 txBufSize, UINT8 *rxBuf, UINT32 rxBufSize);
//串口发送触发LEVEL
enum{
  TX_FIFO_LEVEL_EMPTY=0,
  TX_FIFO_LEVEL_16BYTES,
  TX_FIFO_LEVEL_32BYTES,
  TX_FIFO_LEVEL_48BYTES,
  TX_FIFO_LEVEL_COUNT,
};
//串口接收触发LEVEL
enum{
  RX_FIFO_LEVEL_1BYTE=0,
  RX_FIFO_LEVEL_8BYTES,
  RX_FIFO_LEVEL_16BYTES,
  RX_FIFO_LEVEL_32BYTES,
  RX_FIFO_LEVEL_COUNT,
};
extern BOOL32 Uart_ConfigFIFO(DevHandle devHandle,UINT32 rxTriggerLevel,
                      UINT32 txTriggerLevel);

//轮询方式使用
extern void Uart_Poll(DevHandle devHandle);
extern void Uart_PollAll(void);

extern void Uart_ClearError(DevHandle devHandle);

extern void Uart_Close(DevHandle devHandle);

extern INT32 Uart_Read(DevHandle devHandle, UINT8 *buf,UINT32 bufSize);
extern INT32 Uart_Write(DevHandle devHandle, UINT8 *buf,UINT32 bufSize);
extern INT32 Uart_Flush(DevHandle devHandle);
// extern void uart_configFIFO(DevHandle devHandle,UINT32 rxTriggerLevel,UINT32 txTriggerLevel);
// // extern void uart_setTransferMode(DevHandle devHandle, UINT32 mode);

// //将RingBuf中的数据立即发送出去，返回flush的字节数
// extern INT32 uart_flush(DevHandle devHandle);
// //读取
// extern INT32 uart_read(DevHandle devHandle,UINT8 *buf,INT32 readSize);
// //写入
// extern INT32 uart_write(DevHandle devHandle,UINT8 *buf,INT32 writeSize);

// extern UINT8 uart_getc(DevHandle devHandle);
// extern void uart_putc(DevHandle devHandle, UINT8 c);
// extern void uart_recvData(DevHandle devHandle, char *buf, INT32 toRecvLen);
// extern void uart_sendData(DevHandle devHandle, const char *buf, int sendSize);
// extern void uart_printf(DevHandle devHandle, char *fmt, ...);
// extern void uart_vprintf(DevHandle devHandle, char *fmt, va_list ap);

#endif